package test;

import java.io.File;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.DocumentException;

import aorey.config.FrameworkConfig;
import aorey.database.DataCheck;
import aorey.database.DataConfig;
import aorey.database.config.DataConfigDelete;
import aorey.database.config.DataConfigSelect;
import aorey.nosql.EhcacheUtil;

/**
 * Servlet implementation class a
 */
@WebServlet("/a")
public class a extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public a() {
        super();
        
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		response.getWriter().append("Served at: ").append(request.getContextPath());
		EhcacheUtil framework = (EhcacheUtil) request.getServletContext().getAttribute("aorey");
		try {
			DataConfig dataConfig = new DataConfig(request);
//			DataConfigSelect dataConfigSelect = dataConfig.getSelect("stest");
			DataConfigDelete dataConfigDelete = dataConfig.getDelete("dtest");
			System.out.println(dataConfigDelete.sql);
//			file.createNewFile();
//			DataConfigSelect dataConfigSelect = new DataConfigSelect(request.getRealPath("/")+FrameworkConfig.selectConfig+"/stest.xml");
//			System.out.println(request.getRealPath("/")+FrameworkConfig.selectConfig+"/stest.xml");
//			System.out.println(dataConfigSelect.data_source);
//			System.out.println("/home/csq/Object/javaApp/WebContent/WEB-INF/aorey/select/stest.xml");
		} catch (Exception e) {
			System.out.println("Config Error："+ e.getMessage());
			
			e.printStackTrace();
		}
//		DataCheck dataCheck = new DataCheck();
//		request.getSession().setAttribute("aaa", "11111111111111111");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
